package com.spark.market.service;

import com.spark.market.api.dto.ItemInfo;
import com.spark.market.api.mq.ItemStockMqMessage;
import com.spark.market.api.request.ItemAddParam;
import com.spark.market.api.request.ItemDecreaseParam;
import com.spark.market.api.result.ItemStockDecreaseResult;

public interface ItemCmdCoreService {
    /**
     * 创建商品
     * @param param
     * @return
     */
    public ItemInfo createItem(ItemAddParam param);

    /**
     * 减库存-直接走数据库
     * @param param
     * @return
     */
    public ItemStockDecreaseResult decreaseItemStock(ItemDecreaseParam param);

    /**
     * 通过缓存减库存
     * @param param
     * @return
     */
    public ItemStockDecreaseResult decreaseItemStockByCache(ItemDecreaseParam param);

    /**
     * 增加商品的销量
     * @param itemId
     * @param amount
     */
    void increaseSales(Integer itemId, Integer amount);

    /**
     * 异步扣减库存
     * @param itemStockMqMessage
     */
    void syncDecreaseItemStockByMq(ItemStockMqMessage itemStockMqMessage);
}
